package info.hexin.dubbo.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by infi.he on 2015/4/24.
 */
public class ThreadPool {
    private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(200);

    public ThreadPool() {
    }

    public static void execute(Runnable command) {
        executor.execute(command);
    }

    public static void execute(Runnable command, long delayseconds) {
        executor.schedule(command, delayseconds, TimeUnit.SECONDS);
    }

    public static void shutdown() {
        executor.shutdown();
    }

    public static boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException{
        return executor.awaitTermination(timeout,unit);
    }

    public static void remove(Runnable Task) {
        executor.remove(Task);
    }
}
